//
//  SlideImageView.m
//  Assistant
//
//  Created by 魏延龙 on 2020/8/5.
//  Copyright © 2020 张继明. All rights reserved.
//

#import "SlidImageView.h"
@interface SlidImageView()

// 上方圆形图片
@property(nonatomic, strong) UIImageView *badgeImageView;
// 上方圆形图片下面文字
@property(nonatomic, strong) UILabel *badgelabel;

@end

@implementation SlidImageView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupViews];
    }
    return self;
}

-(void)layoutSubviews {
    // self.height 最好大于180
    self.badgeImageView.frame = CGRectMake((self.frame.size.width - 148)/2, 0, 148, 148);
    self.badgelabel.frame = CGRectMake((self.frame.size.width - 146)/2, (self.frame.size.height - 32), 146, 32);
}

-(void)setupViews {
    
    self.badgeImageView = [[UIImageView alloc] init];
    {
        [self addSubview:self.badgeImageView];
        self.badgeImageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    }
    
    self.badgelabel = [[UILabel alloc] init];
    {
        [self addSubview:self.badgelabel];
        self.badgelabel.backgroundColor = [UIColor colorWithWhite:1 alpha:0.5];
        self.badgelabel.layer.cornerRadius = 16;
        self.badgelabel.layer.masksToBounds = YES;
        self.badgelabel.textAlignment = NSTextAlignmentCenter;
        self.badgelabel.textColor = [UIColor whiteColor];
        self.badgelabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    }
}

-(void)setBadgeImageName:(NSString *)badgeImageName {
    _badgeImageName = badgeImageName;
    self.badgeImageView.image = [UIImage imageNamed:badgeImageName];
}
-(void)setBadgeTitle:(NSAttributedString *)badgeTitle {
    _badgeTitle = badgeTitle;
    [self.badgelabel setHidden:NO];
    self.badgelabel.attributedText = badgeTitle;
}


@end
